package com.tusuo.stds.ui.questionbank;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Point;
import android.view.Display;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ListView;
import android.widget.TextView;

import com.tusuo.stds.R;
import com.tusuo.stds.rest.QuestionBankGroup;


public class QuestionBankBottomTransparentDialog extends Dialog {

    public QuestionBankBottomTransparentDialog(final Activity activity,
                                               String strTotalCount,
                                               String strCorrectCount,
                                               String strWrongCount,
                                               QuestionBankGroup questionBankGroup, int selectedIndex) {
        super(activity, R.style.TranslucentDialog);

        WindowManager windowManager = activity.getWindowManager();
        Display display = windowManager.getDefaultDisplay(); // 获取屏幕宽、高用
        Point point = new Point();
        display.getSize(point);

        // 去掉隐藏的title区域，不然会被点击到
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        getWindow().getDecorView().setPadding(0, 0, 0, 0);
        WindowManager.LayoutParams wmlp = getWindow().getAttributes();
        wmlp.width = WindowManager.LayoutParams.MATCH_PARENT;
        wmlp.height = (int) (point.y * 0.6);    // 高度占屏幕比例
        wmlp.gravity = Gravity.BOTTOM;
        getWindow().setAttributes(wmlp);

        // 设置内容
        setContentView(R.layout.question_bank_dialog);

        setTitle(null);
        setCancelable(true);
        setOnCancelListener(null);

        TextView tvTotalCount = (TextView) findViewById(R.id.question_bank_tv_total_count);
        tvTotalCount.setText(strTotalCount);
        TextView tvCorrectCount = (TextView) findViewById(R.id.question_bank_tv_correct_count);
        tvCorrectCount.setText(strCorrectCount);
        TextView tvWrongCount = (TextView) findViewById(R.id.question_bank_tv_wrong_count);
        tvWrongCount.setText(strWrongCount);

        ListView listView = (ListView) findViewById(R.id.list_question_bank);
        listView.setAdapter(new QuestionBankGroupListAdapter(activity, questionBankGroup.Data,selectedIndex));
    }
}
